<?php

namespace App\Enums;

use App\Traits\EnumMethods;

enum DnsType: string
{
    use EnumMethods;

    case A = 'A';
    case CNAME = 'CNAME';
    case NS = 'NS';
    case MX = 'MX';
    case TXT = 'TXT';
    case SRV = 'SRV';
    case AAAA = 'AAAA';
    case CAA = 'CAA';
    case REDIRECT_URL = 'REDIRECT_URL';
    case FORWARD_URL = 'FORWARD_URL';

    const TYPE_MAP = [
        self::A->value => 'A记录',
        self::CNAME->value => 'CNAME记录',
        self::NS->value => 'NS记录',
        self::MX->value => 'MX记录',
        self::TXT->value => 'TXT记录',
        self::SRV->value => 'SRV记录',
        self::AAAA->value => 'AAAA记录',
        self::CAA->value => 'CAA记录',
        self::REDIRECT_URL->value => '显性URL转发',
        self::FORWARD_URL->value => '隐性URL转发',
    ];

    const SELECT_TYPE_MAP = [
        self::A->value => 'A记录 - 指向IPV4地址',
        self::CNAME->value => 'CNAME记录 - 指向另一个域名',
        self::NS->value => 'NS记录 - 指定其他DNS服务器解析',
        self::MX->value => 'MX记录 - 指向邮件服务器地址',
        self::TXT->value => 'TXT记录 - 通常用作SPF记录(反垃圾邮件)',
        self::SRV->value => 'SRV记录 - 提供特定的服务的服务器',
        self::AAAA->value => 'AAAA记录 - 指向IPv6地址',
        self::CAA->value => 'CAA记录 - CA证书颁发机构授权校验',
        self::REDIRECT_URL->value => '显性URL转发 - 将域名重定向到另外一个地址',
        self::FORWARD_URL->value => '隐性URL转发 - 与显性类似，但是会隐藏真实目标地址',
    ];

    public function toString(): string
    {
        return self::TYPE_MAP[$this->value];
    }
}

